package com.optimatch.ui.view.customComponents.pages;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.MutableComboBoxModel;

import com.optimatch.model.solver.Solution;
import com.optimatch.model.utils.AffichageUtil;

public class ResulatParJourneePanel extends JPanel {
	
	private JComboBox choixJournee;
	private JPanel resultat;
	private JTable table;
	private Object[][] data;
	private JScrollPane scroll;
	
	public ResulatParJourneePanel() {
		super();
		init();
	}

	private void init() {
		this.setLayout(new BorderLayout());
		choixJournee = new JComboBox();
		resultat = new JPanel(new GridLayout(1,1));
		scroll = new JScrollPane();
		resultat.add(scroll);
		this.add(choixJournee, BorderLayout.NORTH);
		this.add(resultat, BorderLayout.CENTER);
	}

//	private void buildResultatPanel() {
//		String[] columnNames = {"Equipe1","Equipe2"};
//		//TODO : prendre les valeurs du mod�le
//		Object[][] data = {
//		{"Eq1", "Eq2"},
//		{"Eq7", "Eq3"}};
//		JTable table = new JTable(data, columnNames);
//		resultat.add(table);
//	}
	public void setListeJournees(){
		MutableComboBoxModel boxModelJournee = new DefaultComboBoxModel();
		for (int i=0;i<Solution.getNombreMatchs();i++) {
			boxModelJournee.addElement(AffichageUtil.getListeJournee()[i]);
		}
		choixJournee.setModel(boxModelJournee);
	}
	public Object[][] getData() {
		return data;
	}
	public void setData(Object[][] data) {
		resultat.remove(scroll);
		table = new JTable(data,new String[]{"Match","Equipe Domicile","Equipe Exterieur"});
		table.setRowHeight(30);
		table.setBackground(new Color(217,226,243));
		scroll = new JScrollPane(table);
		resultat.add(scroll);
		this.data = data;
	}
	public JComboBox getChoixJournee() {
		return choixJournee;
	}
	public void setChoixEquipe(JComboBox choixJournee) {
		this.choixJournee = choixJournee;
	}
	
	
}
